﻿using MrPP.iot;
using MrPP.Restful;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace MrPP.SerriedCabinet
{
    public class TemperatureAndHumidityFactory : GDGeek.Singleton<TemperatureAndHumidityFactory>, IEventFactory
    {

        public Action<Data> onRecevie
        {
            get;
            set;
        }

        public class Data
        {
            public byte area;
            public short temperature;
            public byte humidity;

            public float getTemperature()
            {
                return (float)(temperature) / 10f;
            }
            public float getHumidity()
            {

                return (float)(humidity);
            }
        }
        public string type => "temperatureAndHumidity";
   
        public void post(string data)
        {
            Data evt = JsonUtility.FromJson<Data>(data);
            Debug.Log(JsonUtility.ToJson(evt));

          
            onRecevie?.Invoke(evt);
        }
    }
}